<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML" 4.01"//EN" "http://www.w3.org/TR/html4/strict.dtd">
<!-- Created: May 28, 2002-->
<!--
$Id$
$Header$
$Log$
-->

<html>
<head>
<title>Radiological Equipment Database</title>
<link rev="made" href="mailto:eugenem@ix.netcom.com">
<link rev="home" href="http://home.netcom.com/~eugenem/">
<meta name="author" content="Eugene Mah">
<meta name="description" content="">
<meta name="Keywords" content="">
<meta name="Reply-to" content="eugenem@ix.netcom.com">
<meta http-equiv="Content-Script-Type" content="text/javascript">
<META http-equiv="PICS-Label" content='(PICS-1.1 "http://www.classify.org/safesurf/" l r (SS~~0001))'>
<?PHP
require('functions.inc');
require('dbc.inc');
?>
</head>

<body>
<h1>Radiological Equipment Database</h1>

<!--
This form is used to select a tube for the generator data given the
SurveyID.  When a survey is selected and the form submitted, the
DB is queried to obtain a list of x-ray tubes for the machine
associated with the survey ID.

The user is asked to select from the list of tubes and to
paste the generator data into the text area.  Processing and
insertion of the generator data is handled by SurveyGenDataB.php
-->

<?PHP
if (isset($SurveyID)) {
  // Get the MachineID associated with this survey
  $result = mysql_query("select MachineID from Survey2Machine where SurveyID=\"$SurveyID\"");
  $row = mysql_fetch_row($result);
  $MachineID = $row[0];

  // Get a list of x-ray tubes for this machine
  $Tubes = mysql_query("select TubeID,concat_ws(\" \",HousingModel,HousingSN) as Hsg from Tubes where MachineID=\"$MachineID\" and Active=1");

  // Generate a form to ask the user to select a tube
?>
<h2>Select a tube</h2>
<form action="SurveyGenDataB.php" method="POST">
<input type="HIDDEN" name="SurveyID" value="<?PHP echo $SurveyID; ?>">
<input type="HIDDEN" name="MachineID" value="<?PHP echo $MachineID; ?>">
<p>Select a tube:
<?PHP
echo listbox_field($Tubes,"TubeID","");
?></p>
<!--
Text area for pasting generator data.

Data pasted from the spreadsheet generator data block should consist of
28 columns x 39 rows of tab delimited values.  Only columns 1-4,6,8,
17-19,21,24-28 are used.
-->
<h2>Generator Data</h2>
<p><textarea name="GenData" rows=39 cols=200>Paste selection from spreadsheet</textarea></p>
<p><input type="SUBMIT" value="Add data"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
<hr />
<?PHP
}  // end if(isset($SurveyID))
?>

<h2>Add Generator Data</h2>
<form action="SurveyGenDataA.php" method="POST">
<p>Enter Survey ID: <input name="SurveyID" type="text" size="5" value="<?php echo (isset($SurveyID)||!empty($SurveyID))?$SurveyID:""; ?>" ></p>
<?PHP
/*
  Select the SurveyIDs from TestDates that aren't already in the
  GenData table.
*/
/* 2004-11-22: Don't want to do it this way anymore.  Dropdown lists are getting to long.
$query = "SELECT TestDates.SurveyID 
          FROM TestDates 
		  LEFT JOIN GenData USING (SurveyID) 
		  WHERE GenData.SurveyID IS NULL";

$result = mysql_query($query)
  or die("<p>Unable to execute query: $query<br />" . mysql_error() . "</p>\n");
echo listbox_one_field($result,"SurveyID","");
*/
?>

<p><input type="SUBMIT" value="Select Survey"> / <input type="RESET" value="Reset"> / <a href="index.html" target="_top" >Main</a></p>
</form>
</body>
</html>
